import Koa from 'koa';
// @ts-ignore
import koaRequest from "koa2-request";

import sysConf from "../confg/sys.conf";

const checkToken = async (ctx: Koa.Context, params: { userInfoTypeEnums: 'ADMIN_USER' | 'BUSINESS_USER' | 'BC_USER' | 'SUPPLIER_USER' | 'SAAS_USER' | 'TRADE_USER'}) => {
  const res = await koaRequest(`${sysConf.outApiUrl}/user/check/type`, {
    method: 'GET',
    dataType: 'json',
    headers: {
      token: ctx.header.token
    },
    qs: params,
  });
  console.log(res);
  return JSON.parse(res.body);
}
const setPlatform = async (ctx: Koa.Context, params: { siteId: number, siteContentId: string}) => {
  const res = await koaRequest(`${sysConf.outApiUrl}/saas/platform/site/content`, {
    method: 'GET',
    dataType: 'json',
    headers: {
      token: ctx.header.token
    },
    qs: params,
  });
  return JSON.parse(res.body);
}
export default {
  checkToken,
  setPlatform,
}
